{% extends "docentes/index.html" %}
{% load i18n %}
{% block title %}{% trans 'Página de apresentação das turmas do Docente ' %}{% endblock %}

{% block breadcrumb %}
<ul class="breadcrumb">
	<li>
		<span class="glyphicon glyphicon-home"></span> <a tabindex="2" href="{% url homeDocente %}" title="{% trans 'Home' %}">{% trans 'Home' %}</a>
	</li>
	<li class="active">{% trans 'Turmas do Docente' %}</li>
</ul>
{% endblock %}


{% block menuInfoDocente %} {% endblock %}
{% block menuTurma %}class="active"{% endblock %}

{% block content %}
	<div class="page-header whiteText">
	  <h1>{% trans 'Sumário'%}<small>{% trans ' Ano '%}{{anoActual}} </small></h1>
	</div>
	
	<form id= "form_report" method="post" action ="{%url print_pdf %}" role="form">
		{% csrf_token %}
		<input id = "hidden_inputDados" name ="table_json" type="hidden"/>
		<input id = "dados_report" value ="{%trans 'Turmas do Docente'%}" name ="tituloReport" type="hidden"/>
		<input id = "ano_report" value ="{{anoActual}}" name ="ano" type="hidden"/>
		<input id = "user_report" value ="{{user.first_name}} {{user.last_name}}" name ="user_name" type="hidden"/>
		<input id = "tipoReport" value ="0" name ="tipoReport" type="hidden"/>
		<input id="button_print" value ="{%trans 'Imprimir'%}" type="button" class="btn btn-primary"/>
	</form>
		
	<form id="filter_ano_form" class="form-horizontal" role="form">
		 <div class="form-group whiteText">
	   	 	<div class="col-xs-2">
		      {%for field in form_combo%}
		      	{{ field.label_tag }}: {{ field }}
		      {%endfor%}  
	    	</div>
	  	</div>
	</form>
	
	<table cellpadding="0" cellspacing="0" border="0" class="display sumary_table" id="special_table" width="100%">
		<thead>	
			<tr>
				<th class="cabecalho_sumario">Curso</th>
				<th class="cabecalho_sumario">Turma</th>
			</tr>
		</thead>
		<tbody>
			{%for id, turma, curso in lista%}
				<tr>
					<td>{{ curso }}</td>
					<td>{{ turma }}</td>
			
				</tr>
			{%endfor%}
		</tbody>
	</table>
	
	<script type="text/javascript">
		$(document).ready(function() {
			$('#special_table').dataTable({
				"oLanguage": {
		            "sUrl": "/static/dataTables/lang/pt-pt.txt"
		        },
		         "sPaginationType": "full_numbers",
		         "sDom": '<"dataTables_special_bar"l><"dataTables_special_bar"if><"whiteBox"rt><"pagination_box"p>'
		        
		        	
			});
			
		$('.hasTooltip').tooltip({"container": false});
		
		
		$("#button_print").click(function(){
			var table = $('#special_table').tableToJSON();
			var dados_tableStr = JSON.stringify(table);
			
			$("#hidden_inputDados").val(dados_tableStr);
			$("#form_report").submit();
		});
		
		
		/*
		$("#pois").click(function(){
			var table = $('#special_table').tableToJSON();
			alert(JSON.stringify(table))
			var value = $("#id_descricao").children(':selected').val();
	    	var csrftoken = getCookie('csrftoken');
	      	$.ajax({
	      		type: "POST",
	          	url:"",
	          	data:{table_json:JSON.stringify(table)},
	          	beforeSend: function( xhr ) {xhr.setRequestHeader("X-CSRFToken", csrftoken);},
	          	success: function(data) {
	          		//$("body").append('<iframe src="?'+ data + '" style="display: none;" ></iframe>');
	          		//window.location.href = "#"
	            		            	
	            },
	            error: function(rs, e) {
	            	 
	            }
	     	});	
			//alert(JSON.stringify(table));
			*/	
		});
	</script>
{% endblock %}